home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / devel / tcl / tclx7_31.z / tclx7_31 / tcldev / tclX7.3a-p1 / tests / convlib.test < prev    next >
Encoding:
Text File  |  1994-01-23  |  2.5 KB  |  80 lines

  1. #
  2. # convlib.test
  3. #
  4. # Tests for tcl.tlib convert_lib routine.
  5. #---------------------------------------------------------------------------
  6. # Copyright 1992-1993 Karl Lehenbauer and Mark Diekhans.
  7. #
  8. # Permission to use, copy, modify, and distribute this software and its
  9. # documentation for any purpose and without fee is hereby granted, provided
  10. # that the above copyright notice appear in all copies.  Karl Lehenbauer and
  11. # Mark Diekhans make no representations about the suitability of this
  12. # software for any purpose.  It is provided "as is" without express or
  13. # implied warranty.
  14. #------------------------------------------------------------------------------
  15. # $Id: convlib.test,v 3.0 1993/11/19 06:57:14 markd Rel $
  16. #------------------------------------------------------------------------------
  17. #
  18.  
  19. if {[info procs test] == ""} then {source testlib.tcl}
  20. eval $SAVED_UNKNOWN
  21.  
  22. catch {unlink -nocomplain [glob convlib.tmp/*]}
  23. catch {rmdir convlib.tmp}
  24. mkdir convlib.tmp
  25.  
  26. # Create a temporary source files and generate an index.
  27.  
  28. loop num 0 5 {
  29.     set fh [open convlib.tmp/tmp${num}.tcl w]
  30.     puts $fh "proc LoadProc${num}A {} {return @LoadProc${num}A@}"
  31.     puts $fh "proc LoadProc${num}B {} {return @LoadProc${num}B@}"
  32.     close $fh
  33. }
  34.  
  35. set fh [open convlib.tmp/init.tcl w]
  36. puts $fh "proc InitTcl {} {return @InitTcl@}"
  37. close $fh
  38.  
  39. auto_mkindex convlib.tmp *.tcl
  40.  
  41. # Proc that validates the library by executing procs out of it.
  42.  
  43. proc LibValidate {testid testname} {
  44.     loop num 0 5 {
  45.         Test $testid.1 $testname {
  46.             LoadProc${num}A
  47.         } 0 "@LoadProc${num}A@"
  48.         Test $testid.2 $testname {
  49.             LoadProc${num}B
  50.         } 0 "@LoadProc${num}B@"
  51.         Test $testid.3 $testname {
  52.             InitTcl
  53.         } 1 {invalid command name "InitTcl"}
  54.     }
  55. }
  56.  
  57. #
  58. # Now convert and load the library, see if we can actually use it.
  59. #
  60.  
  61. Test convlib-1.1 {Convert library tests} {
  62.     unlink -nocomplain {convlib.tmp/tmp.tlib convlib.tmp/tmp.tndx}
  63.     convert_lib convlib.tmp/tclIndex convlib.tmp/tmp  "init.tcl"
  64.     list [file exists convlib.tmp/tmp.tlib] [file exists convlib.tmp/tmp.tndx]
  65. } 0 {1 1}
  66.  
  67. Test convlib-1.2 {Convert library tests} {
  68.     unlink -nocomplain {convlib.tmp/tmp.tlib convlib.tmp/tmp.tndx}
  69.     convert_lib convlib.tmp/tclIndex convlib.tmp/tmp.tlib "init.tcl"
  70.     list [file exists convlib.tmp/tmp.tlib] [file exists convlib.tmp/tmp.tndx]
  71. } 0 {1 1}
  72.  
  73. loadlibindex convlib.tmp/tmp.tlib
  74. LibValidate convlib-1.3 {Convert library tests}
  75.  
  76. catch {unlink -nocomplain [glob convlib.tmp/*]}
  77. catch {rmdir convlib.tmp}
  78. rename unknown {}
  79.  
  80.